# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer:
pkgname=clingo
pkgver=5.4.0
pkgrel=1
pkgdesc="A grounder and solver for logic programs"
url="https://potassco.org/clingo/"
arch="all"
license="MIT"
depends="!clasp" # both provide /usr/bin/clasp
makedepends="python3-dev cmake"
subpackages="$pkgname-dev py3-$pkgname:py"
options="!check"
source="https://github.com/potassco/clingo/archive/v$pkgver/clingo-$pkgver.tar.gz
	python38.patch"
replaces="gringo" # backwards compatibility

build() {
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None \
		-DCLINGO_REQUIRE_PYTHON=ON \
		-DCLINGO_BUILD_PY_SHARED=ON \
		-DPYCLINGO_USER_INSTALL=OFF \
		-DCLINGO_REQUIRE_LUA=OFF
	make -C build
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

py() {
	pkgdesc="Python bindings for clingo"
	depends="python3"

	mkdir -p "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

sha512sums="23277b7523dc78c99e0a0691e95ccb859a27db18abb9e9864011162e4ead0e050e70c3c71f61dfc9046cfcb30dad06cf32c656cc3c722f73a6f40571fae12b0c  clingo-5.4.0.tar.gz
0049f08e1f876b22f3f0c87b140efd8534bb079d26ea53670a66b5162ce1a400d69225044c3d65e446256e8d7f4c39154ef0e5761eeab7fb03277a6e4586c7ca  python38.patch"
